package com.zj.study.test;

import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.function.UnaryOperator;

/**
 * @author ZhaoJiu
 * @CreateTime: 2021/7/19 10:48
 * @Description:
 */
public class FunctionDemo {

    public static void main(String[] args) {
        //supplier 没有输入 只有一个输出
        Supplier<String> supplier = ()->"this is supplier demo";
        System.out.println("supplier = " + supplier.get());

        //supplier 只有一个参数 没有输出
        Consumer<String> consumer = i->System.out.println("this is consumer demo  -- > "+ i);
        consumer.accept("consumer");

        //输入T 输出R
        Function<Integer, Integer> function = i -> i*i;
        System.out.println("function = " + function.apply(9));

        //输入T 输出T
        UnaryOperator<Integer> operator = i ->i*i;
        System.out.println("operator = " + operator.apply(9));
    }
}
